package com.project.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;

public class FileUpload {
	public enum uploadContentType {
		txt, pdf, doc, xls;
	} // 限制上传的后缀名

	private static final int maxSize = 8192;

	private static String savingPath = "d:/";

	public static boolean uploadFile(String saveAs, String fileName) {
		try {
			// 此处为最简单的文件拷贝方法
			java.io.InputStream is = new FileInputStream(fileName);
			java.io.OutputStream os = new FileOutputStream(savingPath + saveAs);// 上传到d盘根目录
			byte buffer[] = new byte[maxSize];
			int count = 0;
			while ((count = is.read(buffer)) > 0)
				os.write(buffer, 0, count);
			os.close();
			is.close();
		} catch (Exception e) {
			System.out.println(e);
			return false;
		}
		return true;
	}

}
